package service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import to.BeansTO;
import to.JobTO;
import to.MachineTO;
import to.SiloTO;
import to.WeightTO;
import dao.CoffeeDAO;

public class CoffeeService {
	private CoffeeDAO dao;
	public CoffeeService(CoffeeDAO dao){
		this.dao = dao;
	}
	
	//Machine 진행중레시피 변경
	public void updateMachinePrograssRecipe(String machineName,String recipe)throws SQLException{
		HashMap map = new HashMap();
		map.put("machineName", machineName);
		map.put("recipe", recipe);
		dao.updateMachinePrograssRecipe(map);
	}
	
	//machine 진행중레시피 가져오기
	public String selectMachinePrograssRecipe(String machineName)throws SQLException{
		return dao.selectMachinePrograssRecipe(machineName);
	}
	
	//
	public void updateMaterialTotalWeight(String materialName, int weight)throws SQLException{
		HashMap map = new HashMap();
		map.put("materialName", materialName);
		map.put("weight", weight);
		dao.updateMaterialTotalWeight(map);
	}
	
	//재료량 가져오기
	public int selectMaterialTotalWeight(String materialName)throws SQLException{
		return dao.selectMaterialTotalWeight(materialName);
	}
	
	//machine 대기작업 가져오기
	public int selectMachineWaitingJob(String machineName)throws SQLException{
		return dao.selectMachineWaitingJob(machineName);
	}
	
	//검수된 원두 정보 등록
	public void insertBeansInfo(BeansTO bto)throws SQLException{
		dao.insertBeansInfo(bto);
	}
	
	//silo 상태 변경
	public void updateSiloStatus(String siloName,  int weight)throws SQLException{
		HashMap map = new HashMap();
		map.put("siloName", siloName);
		map.put("weight", weight);
		dao.updateSiloStatus(map);
	}
	
	//machine 상태 변경
	public void updateMachineStatus(String machinName, String MachineStatus)throws SQLException{
		HashMap map = new HashMap();
		map.put("machineName", machinName);
		map.put("machineStatus", MachineStatus);
		dao.updateMachineStatus(map);
	}
	
	//silo Beans 총중량 가져오기
	public int selectSiloBeansTotalWeight(String siloName)throws SQLException{
		return dao.selectSiloBeansTotalWeight(siloName);
	}
	
	//배전두silo BigBeans 총중량 가져오기
	public int selectBigBeansTotalWeight()throws SQLException{
		return dao.selectBigBeansTotalWeight();
	}
	
	//배전두silo BigBeans 총중량 변경
	public void updatetBigBeansTotalWeight(int weight)throws SQLException{
		dao.updatetBigBeansTotalWeight(weight);
	}
	
	
	
	//machine 상태, 대기작업 변경
	public void updateMachineWaitingJob(String machinName, int waitingJob)throws SQLException{
		HashMap map = new HashMap();
		map.put("machineName", machinName);
		map.put("waitingJob", waitingJob);
		dao.updateMachineWaitingJob(map);
	}
	
	//작업 내용 등록
	public void insertJobInfo(JobTO jto)throws SQLException{
		dao.insertJobInfo(jto);
	}
	
	//생산종류포함 작업내용 등록
	public void insertJobByArticleTypeInfo(JobTO jto)throws SQLException{
		dao.insertJobByArticleTypeInfo(jto);
	}
	
	//생산종류 및 불량 포함 작업내용 등록
	public void insertJobByArticleTypeFaultInfo(JobTO jto)throws SQLException{
		dao.insertJobByArticleTypeFaultInfo(jto);
	}
	
	//청소 일자 등록
	public void updateCleanDate(String machineName, String cleanDate)throws SQLException{
		HashMap map = new HashMap();
		map.put("machineName", machineName);
		map.put("cleanDate", cleanDate);
		dao.updateCleanDate(map);
	}
	
	
	
	//모든재료정보 가져오기
	public ArrayList<BeansTO> selectAllMaterialInfo() throws SQLException {
		return dao.selectAllMaterialInfo();
	}
	
	//모든재료 갯수 가져오기
	public ArrayList<WeightTO> selectAllMaterialWeightIngo()throws SQLException{
		return dao.selectAllMaterialWeightIngo();
	}
	
	//모든 머신 정보 가져오기
	public ArrayList<MachineTO> selectAllMachineInfo()throws SQLException{
		return dao.selectAllMachineInfo();
	}
	//모든 silo정보 가져오기
	public ArrayList<SiloTO> selectAllSiloInfo()throws SQLException{
		return dao.selectAllSiloInfo();
	}
	
	//모든 작업정보 가져오기
	public ArrayList<JobTO> selectAllJobInfo()throws SQLException{
		return dao.selectAllJobInfo();
	}
	
	//특정 작업정보 가져오기
	public ArrayList<JobTO> selectJobInfoByJobName(String jobName)throws SQLException{
		return dao.selectJobInfoByJobName(jobName);
	}
}
